package com.yht.consumer.api;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.yht.consumer.feign.TestFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 鱼仔
 * @date 2021/8/9 5:20 下午
 * 概要
 */
@RestController
public class TestController {

    @Autowired
    private TestFeignService testFeignService;

    @HystrixCommand(fallbackMethod = "getDefault")
    @GetMapping(value = "/fgpc")
    public String getFgPc() {
        String pc = testFeignService.getPc();
        System.out.println(pc);
        return pc;
    }


    /**
     * 服务降级返回的默认方法
     *
     * @return
     */
    public String getDefault() {
        return "被服务降级了";
    }
}
